<div class="pagination">
    <ul>
        {% for p in posts.paginator.page_range %}
            <li {% ifequal p posts.number %}class="active"{% endifequal %}>
                <a href="?page={{ p }}">{{ p }}</a>
            </li>
        {% endfor %}
    </ul>
</div>